import { getPersonDetail } from "@/api"
export default {
  data() {
    return {
      personId: uni.getStorageSync("person-id").slice(2) || undefined,
      userInfo: {}
    }
  },
  methods: {
    getPersonDetail(update) {
      if (
        !getApp().globalData.userInfo ||
        !getApp().globalData.userInfo.id ||
        update
      ) {
        let param = {
          param: JSON.stringify({
            personId: this.personId,
          }),
          where: "",
          slaveInfo: 1,
        };
        return getPersonDetail(param).then((res) => {
          this.userInfo = res.data || res;
          if (
            this.userInfo.pic &&
            this.userInfo.pic.indexOf("img.job1001.com/myUpload/pic.gif") >= 0
          ) {
            this.userInfo.pic = this.$defalutAvatar;
          }
          getApp().globalData.userInfo = this.userInfo;
          return res
        });
      } else {
        this.userInfo = getApp().globalData.userInfo;
        return new Promise((resolve, reject) => {
          resolve();
        });
      }
    },
  }
}